package com.shanxia.codec.enums;

import java.util.Objects;

public enum ModuleWarningEnum {

    OUTPUT_OVERVOL(1, 0, "输出过压"),
    OVERTEMPE_PROTECTION(1, 1, "过温保护"),
    OUTOF_CONTROL(1, 2, "模块失控"),
    FAN_FAIL(1, 3, "风扇故障"),
    DC_NOT_PROOFREAD(1, 4, "DC未较准"),
    OUTPUT_INVERSE(1, 5, "输出反接"),
    OUTPUT_UNDERVOL(1, 6, "输出欠压"),
    ADDR_CONFILICT(1, 7, "模块地址冲突"),
    CURRENT_UNBALANCE(2, 0, "均流不平衡度"),
    CAN_COMMU_FAIL(2, 1, "CAN通讯失败"),
    PFC_FAULT(2, 2, "PFC故障"),
    OTHER_FAIL(2, 3, "其他故障(不可恢复故障)"),
    DC_SS_FAIL(2, 4, "DC软启动失败"),
    DC_RELAY_FAULT(2, 5, "DC继电器故障"),
    SCI_COMMU_EXCEPTION(2, 6, "SCI通讯异常"),
    ACVOL_POWERDOWN_RAPID(2, 7, "交流电压快速掉电"),
    AC_CURRENT_PHASE(3, 0, "AC侧电流缺相"),
    OUTPUT_A_PHASE(3, 1, "交流输入A相缺相"),
    OUTPUT_B_PHASE(3, 2, "交流输入B相缺相"),
    OUTPUT_C_PHASE(3, 3, "交流输入C相缺相"),
    POS_BUSBAR_HIGHVOL(3, 4, "正母线电压过高"),
    NEG_BUSBAR_HIGHVOL(3, 5, "负母线电压过高"),
    BUSBAR_LOWVOL(3, 6, "母线电压过低"),
    BUSBAR_VOL_EXCEPTION(3, 7, "母线电压异常"),
    GRID_OVERLOAD(4, 0, "电网侧过载"),
    GRID_OVERLOAD_OUTCOUNT(4, 1, "电网侧过载超次"),
    INPUT_OVERCURRENT(4, 2, "交流输入过流"),
    GRID_HIGHVOL(4, 3, "电网电压过高"),
    GRID_LOWVOL(4, 4, "电网电压过低"),
    GIRD_HIGH_FREQUENCY(4, 5, "电网频率过高"),
    GIRD_LOW_FREQUENCY(4, 6, "电网频率过低"),
    GIRD_LOCK_FAIL(4, 7, "电网快速锁相失败"),
    UNKNOWN(99, 99, "未知");


    public static ModuleWarningEnum getByPos(int bytePos, int bitPos) {
        for (ModuleWarningEnum enums : ModuleWarningEnum.values()) {
            if (Objects.equals(enums.bytePos, bytePos) && Objects.equals(enums.bitPos, bitPos) ) {
                return enums;
            }
        }
        return ModuleWarningEnum.UNKNOWN;
    }



    ModuleWarningEnum(int bytePos, int bitPos, String descr) {
        this.bytePos = bytePos;
        this.bitPos = bitPos;
        this.descr = descr;
    }

    public int bytePos;
    public int bitPos;
    public String descr;
}
